package com.ruoyi.web.controller.market.special;

import java.util.List;
import java.util.Map;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.db.domain.SpecialOperatorLog;
import com.ruoyi.special.service.ISpecialOperatorLogService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.web.wapper.SpecialOperatorLogWapper;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 操作日志Controller
 * 
 * @author ruoyi
 * @date 2023-06-15
 */
@Controller
@RequestMapping("/special/operatorlog")
public class SpecialOperatorLogController extends BaseController
{
    private String prefix = "special/operatorlog";

    @Autowired
    private ISpecialOperatorLogService specialOperatorLogService;

    @RequiresPermissions("special:operatorlog:view")
    @GetMapping("/{infoId}")
    public String operatorlog(@PathVariable("infoId")String Id,ModelMap map)
    {
        map.put("infoId",Id);
        return prefix + "/operatorlog";
    }

    /**
     * 查询操作日志列表
     */
    @RequiresPermissions("special:operatorlog:view")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(SpecialOperatorLog specialOperatorLog)
    {
        startPage();
        List<Map<String, Object>> mapList = specialOperatorLogService.selectSpecialOperatorLogListMap(specialOperatorLog);
        mapList = new SpecialOperatorLogWapper(mapList).wrap();
        return getDataTable(mapList);
    }

    /**
     * 导出操作日志列表
     */
    @RequiresPermissions("special:operatorlog:export")
    @Log(title = "操作日志", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(SpecialOperatorLog specialOperatorLog)
    {
        List<SpecialOperatorLog> list = specialOperatorLogService.selectSpecialOperatorLogList(specialOperatorLog);
        ExcelUtil<SpecialOperatorLog> util = new ExcelUtil<SpecialOperatorLog>(SpecialOperatorLog.class);
        return util.exportExcel(list, "操作日志数据");
    }

    /**
     * 新增操作日志
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存操作日志
     */
    @RequiresPermissions("special:operatorlog:add")
    @Log(title = "操作日志", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(SpecialOperatorLog specialOperatorLog)
    {
        return toAjax(specialOperatorLogService.insertSpecialOperatorLog(specialOperatorLog));
    }

    /**
     * 修改操作日志
     */
    @RequiresPermissions("special:operatorlog:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        SpecialOperatorLog specialOperatorLog = specialOperatorLogService.selectSpecialOperatorLogById(id);
        mmap.put("specialOperatorLog", specialOperatorLog);
        return prefix + "/edit";
    }

    /**
     * 修改保存操作日志
     */
    @RequiresPermissions("special:operatorlog:edit")
    @Log(title = "操作日志", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(SpecialOperatorLog specialOperatorLog)
    {
        return toAjax(specialOperatorLogService.updateSpecialOperatorLog(specialOperatorLog));
    }

    /**
     * 删除操作日志
     */
    @RequiresPermissions("special:operatorlog:remove")
    @Log(title = "操作日志", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(specialOperatorLogService.deleteSpecialOperatorLogByIds(ids));
    }
}
